package yudisium;


import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;


public class DataHandler {
    // string „localhost‟ anda ganti dengan IP server yang digunakan
//Kelompok 7
    String jdbcUrl = "jdbc:oracle:thin:@localhost:1521:XE";
    String userid = "hr";
    String password = "bulan";
    Connection conn;
    Statement stmt;
    ResultSet rset;
    String query;
    String sqlString;

    public DataHandler() {
    }

    public void getDBConnection() {
        try {
            OracleDataSource ds = null;
            ds = new OracleDataSource();
            ds.setURL(jdbcUrl);
            conn = ds.getConnection(userid, password);
            System.out.println("Koneksi berhasil");

        } catch (SQLException ex) {
            System.out.println("Masih belum konek");
        }
    }

    public void close() {
        try {
            conn.close();
        } catch (SQLException ex) {
            System.out.println("Tidak bisa tutup koneksi");
        }
    }
     public static void main(String[] args) throws SQLException {
        DataHandler datahandler = new DataHandler();
        datahandler.getDBConnection();
        datahandler.close();
    }
}


